Flash MX Professional 2004 Data Integration Using Microsoft Active Server Pages (ASP)
Table of Contents
ASP Sending the Initial Data for Flash
This article uses an ASP example called RDBMS-ASP2.asp. A small subset of the
code in this file starts the application by supplying to Flash all
of the entries in the Contacts table of the RDBMS-ASP2.mdb Access database.
The process starts when Flash (Contacts_xmlcon to be exact) sends a request
with a parameter called func. The func param in Flash
is data-bound to a constant called GetContacts. You can see the
following code executes in the ASP when it receives this request:
select case func
case "GetContacts":
rs1.Open "select * from Contacts order by name",cnn
Do Until rs1.EOF
set recElement = ResultsPacket.createElement("rec")
for i = 0 to rs1.Fields.Count - 1
recElement.setAttribute rs1(i).name, rs1(i).value
ResultsPacket.lastChild.appendChild recElement
next
rs1.MoveNext
Loop
rs1.close
case . . .
.
.
end select
This code fills out the XML document for return to Flash to populate the Contacts_ds DataSet. This XML document is called ResultsPacket, but it is actually just an array of contacts going back to Flash. It is only when called by SaveContacts_xmlcon that ASP sends an actual results packet for the DataSet.
You can test your installation by putting the following URL in your Microsoft Internet Explorer browser address window and pressing Enter:
http://yourserver/yourexampledir/rdbms-asp2.asp?test=1&func=GetContacts
The test=1 parameter tells the ASP that this call does not have
an XML document of parameters so it gets the func parameter from
the URL itself. If you get a blank screen in response, just append a space
to the URL in the browser address window and press Enter. The XML response
with all the contacts will appear; this is the data that the ASP document sends
to Flash.
GetContacts is the only function you can test from the browser
directly because the SaveContacts function requires the update
packet to be in an XML post document—the way SaveContacts_xmlcon sends it.
You could modify the ASP to get an update packet off the URL, but what's the
point? Putting an XML document on the URL just to test the function from the
browser is a bit of overkill (insanity, rather).